package demo2;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

//@Service
//@Controller
//@Repository
@Component
public class User {
    public void setUsername(String username) {
        this.username = username;
    }

    public void setAge(String age) {
        this.age = age;
    }

    public String getUsername() {
        return username;
    }

    public String getAge() {
        return age;
    }

    //@Value注解如果定义在属性上，Spring容器在创建当前对象时会用它来初始化该属性，也可以加在set方法上
    @Value("嘦姕")
    private String username;
    @Value("18")
    private String age;

    @Override
    public String toString() {
        return "User{" +
                "username='" + username + '\'' +
                ", age='" + age + '\'' +
                '}';
    }

    public void sayHi(){
        System.out.println("hi");
    }
}
